import sqlite3

conn = sqlite3.connect('../main/sqlite3/ssh.db')
c = conn.cursor()

# 创建ssh表
# c.execute('''create table ssh
#         (ID INTEGER NOT NULL PRIMARY KEY,
#         NAME varchar(99) NOT NULL,
#         IP varchar(28) NOT NULL,
#         PORT INT NOT NULL,
#         USER varchar(28) NOT NULL,
#         PASSWD varchar(99) NOT NULL
#     );''')

# 插入测试主机
# c.execute("INSERT INTO ssh (NAME,IP,PORT,USER,PASSWD) \
#       VALUES ('114.115.248.128',6666,'root','Esxi0000.')")
# c.execute("INSERT INTO ssh (NAME,IP,PORT,USER,PASSWD) \
#       VALUES ('114.115.248.128',6666,'test','Esxi0000.')")

# 查询数据
cursor = c.execute("select * from ssh;")
for row in cursor:
    print(row[0],row[1],row[2],row[3],row[4])
conn.commit()
conn.close()